<?php

class ux_tx_ttnews_TCAform_selectTree extends tx_ttnews_TCAform_selectTree  {

	function setDefVals() {
		if (!is_int($this->row['uid'])) { // defVals only for new records
			$defVals = t3lib_div::_GP('defVals');

			if (is_array($defVals) && $defVals[$this->table][$this->field]) {
				$defCat = $defVals[$this->table][$this->field];
				
				if(stristr($defCat,',')) $defCatArray=explode(',',$defCat);
				else $defCat=array($defCatArray);
				/**
				 * TODO:
				 * check for allowed categories
				 */
				if ($defCatArray) {
					for($i=0; $i<count($defCatArray); $i++)
					{
						$defCat=$defCatArray[$i];
						
						$row = t3lib_BEfunc::getRecord('tt_news_cat', $defCat);
						$title = t3lib_BEfunc::getRecordTitle($this->table,$row);
	
						$itemFormElValue[]= $defCat.'|'.$title;
						$category[]= $defCat.'|'.$title;
					}
					$this->PA['itemFormElValue']=implode(',',$itemFormElValue);
					$this->row['category']=implode(',',$category);
				}
			}
		}
	}


}



?>